# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: jason ryan <jasonwryan@gmail.com>
# Contributor: Christian Rebischke <chris.rebischke@archlinux.org>

pkgbase=profanity
pkgname=('profanity' 'profanity-gtk')
pkgver=0.13.1
pkgrel=4
epoch=1
pkgdesc='Console based XMPP client'
url='http://www.profanity.im'
arch=('loong64' 'x86_64')
license=('GPL3')
_clidepends=(
  'libcurl.so' 'libncursesw.so' 'expat' 'glib2' 'libotr'
  'libnotify.so' 'libgpgme.so' 'python' 'libgcrypt' 'libsignal-protocol-c'
  'glibc' 'libreadline.so' 'libassuan' 'libgpg-error' 'libstrophe.so'
  )
_gtkdepends=(
  'libgtk-3.so' 'libxss' 'libx11' 'gdk-pixbuf2' 'cairo'
  )
makedepends=(
  ${_clidepends[@]} ${_gtkdepends[@]} 'autoconf-archive'
  )
checkdepends=('cmocka')
source=(https://github.com/profanity-im/profanity/archive/${pkgver}/${pkgbase}-${pkgver}.tar.gz)
sha256sums=('4b1d376115cde47fff2a266aaf3c14eaa62c191d2409f65d611d776a2d28bf7e')
sha512sums=('8d7bf0f54266d972470f4f982276036f57f9bc3febd4de46c332e86eaaf932d62b8be8858b3572811849b1a501e508f9652f93ee0499d99da13171f88ba26925')
b2sums=('cf7e7daa8f5c2175c615adfb056c33ee7c35c60cdc84cb0016854cf2413113e44713f928b1ca49f96e8aa2a81e6285f5299382bc1abcf44fad9dcc5a79d05974')

prepare() {
  cd ${pkgname}-${pkgver}

  mkdir -p m4
  autoreconf -fiv
  cp -a "${srcdir}"/${pkgname}-${pkgver}{,-gtk}
}

build() {
  echo "Building non-gtk variant..."
  (cd ${pkgname}-${pkgver}
    ./configure \
      --prefix=/usr \
      --disable-icons-and-clipboard \
      --without-xscreensaver \
      --enable-notifications \
      --enable-python-plugins \
      --enable-c-plugins \
      --enable-plugins \
      --enable-otr \
      --enable-omemo \
      --enable-pgp
    sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
    make
  )
  echo "Building gtk variant..."
  (cd ${pkgname}-${pkgver}-gtk
    ./configure \
      --prefix=/usr \
      --enable-icons-and-clipboard \
      --with-xscreensaver \
      --enable-notifications \
      --enable-python-plugins \
      --enable-c-plugins \
      --enable-plugins \
      --enable-otr \
      --enable-omemo \
      --enable-pgp
    sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
    make
  )
}

package_profanity() {
  depends=(
    ${_clidepends[@]}
  )
  cd ${pkgbase}-${pkgver}
  make DESTDIR="${pkgdir}" install
}

package_profanity-gtk() {
  pkgdesc+=' (gtk support)'
  depends=(
    ${_clidepends[@]} ${_gtkdepends[@]}
  )
  provides=('profanity')
  conflicts=('profanity')
  cd ${pkgbase}-${pkgver}-gtk
  make DESTDIR="${pkgdir}" install
}

# vim: ts=2 sw=2 et:
